subscribed.event

An event structure representing a one-to-many function/delegate relationship.

  • Declaration

    struct Event(T) if (isCallable!T);

    An event structure representing a one-to-many function/delegate relationship. It mimics a function by overriding the call operator. It also implements the bidirectional range interface.

    Parameters

    T

    The listener type this event contains.

    • Declaration

      alias ListenerType = T;

      The listeners' type.

    • Declaration

      alias ReturnType = void;

      The event's return type.

    • Declaration

      alias ParamTypes = ParameterTypeTuple!T;

      The event's argument type tuple.

    • Declaration

      const size_t size();

      The number of listeners.

    • Declaration

      auto listeners();

      A range array of all the listeners.

    • Declaration

      const bool empty();

      A boolean property indicating whether there are listeners. Part of the bidirectional range interface.

    • Declaration

      const T front();

      Get the first listener or throw an error if there are no listeners. Part of the bidirectional range interface.

    • Declaration

      void popFront();

      Remove the first listener or throw an error if there are no listeners. Part of the bidirectional range interface.

    • Declaration

      void prepend(T[] listeners...);

      Prepend listeners to the listener collection.

      Parameters

      T[] listeners

      The listeners to insert.

    • Declaration

      const T back();

      Get the last listener or throw an error if there are no listeners. Part of the bidirectional range interface.

    • Declaration

      void popBack();

      Remove the last listener or throw an error if there are no listeners. Part of the bidirectional range interface.

    • Declaration

      void append(T[] listeners...);

      Appends a listener to the listener collection.

      Parameters

      T[] listeners

      The listeners to insert.

    • Declaration

      void remove(T[] listeners...);

      Removed all occurrences of the given listeners.

      Parameters

      T[] listeners

      The listeners to remove.

    • Declaration

      void clear();

      Clears all listeners.

    • Declaration

      void call(ParamTypes params);

      Calls all the registered listeners in order.

      Parameters

      ParamTypes params

      The param tuple to call the listener with.

    • Declaration

      void opCall(ParamTypes params);

      Aliases call.

    • Declaration

      auto save();

      Copies the event to allow multiple range-like iteration. Part of the bidirectional range interface.

    • Declaration

      auto opSlice();

    • Declaration

      void opOpAssign(string s : "~")(T listener);

      Aliases append.

    • Declaration

      void opOpAssign(string s : "-")(T listener);

      Aliases remove.